<?php
defined('BY_JYA') or exit('error');

$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'detail';

if($_RQ['op']=='detail'){
	//刷新阅读次数
	pdo_update('core_account_product',array('readnum +='=>1),array('id'=>$_SESSION['id'],'uniacid'=>$_SESSION['uniacid']));
	//获取热门
	$pindex = max(1, intval($_RQ['page']));
	$psize = 6;
	$total='';
	$fields=array('id','title','group_id','createtime','readnum','tuijian','biaoqian','status','pingfen','price','qrcode','picurl');
	$return['hots']=pdo_getslice('core_account_product',array('uniacid'=>$_SESSION['uniacid'],'tuijian '=>1),array($pindex,$psize),$total,$fields,'','id desc');
	$return['good']=pdo_getslice('core_account_product',array('uniacid'=>$_SESSION['uniacid']),array($pindex,$psize),$total,$fields,'','pingfen desc');
	//获取文章数据
	$return['item']=pdo_get('core_account_product',array('id'=>$_SESSION['id'],'uniacid'=>$_SESSION['uniacid']),array('id','title','picurl','group_id','createtime','biaoqian','slide','readnum','status','desc','price','qrcode','content'));
	$return['item']['readnum']=$return['item']['readnum']+$return['item']['readnum'];
	//获取标签
	$biaoqian=explode(';',$return['item']['biaoqian']);
	$bqs=pdo_get('core_account_product_biaoqian',array('uniacid'=>$_SESSION['uniacid']),array('bqs'));
	$bqs=explode(' ',$bqs['bqs']);
	$return['biaoqian']=array();
	foreach($biaoqian as $key => $value){
		if($value != ''){
			$return['biaoqian'][$key] = $bqs[$value];
		}
	}
	unset($return['item']['readnum']);
	$return['item']['createtime']=date('20y-m-d',$return['item']['createtime']);
	$return['fenlei']=pdo_getall('core_account_product_fenlei',array('uniacid'=>$_SESSION['uniacid']),array('id','title'));
	$return['item']['fenleiurl']=custom_url('core/article.list//id='.$return['item']['group_id'],true);
	$return['item']['fenlei']=$return['fenlei'][$return['item']['group_id']]['title'];
	$return['item']['slide']=json_decode($return['item']['slide'],true);
	//$return['item']['content'] = str_replace('&nbsp;','',$return['item']['content']);
	$return['item']['desc'] = $return['item']['desc'] ? $return['item']['desc'] : cfc('tools')->substr($return['item']['content'],0,36);
	$return['sharedata'] = array(
		'title'=>$return['item']['title'] . '-' . $_SESSION['account']['title'],
		'desc'=>$return['item']['desc'],
		'picurl'=>$return['item']['picurl'],
	);
	$return['account']=pdo_get('core_accounts',array('uniacid'=>$_SESSION['uniacid']));
	set_html('title',$return['item']['title']).'-'.$return['account']['name'];
	$return['extradata']=array();
	//获取站点内容页模板
	if($_RQ['siteid'] && $_SESSION['os']=='windows'){
		$siteid=intval($_RQ['siteid']);
		$return['tpl']= cfc('template')->get_html($siteid,'product');
		$return['htmls']=<<<TPL
<div ng-include="tomedia(pagedata.tpl.head_html)"></div>
<div ng-include="tomedia(pagedata.tpl.type)"></div>
<div ng-include="tomedia(pagedata.tpl.foot_html)"></div>
TPL;
	}
	exi($return);
}
if($_RQ['op']=='content'){
	$content=pdo_getcolumn('core_account_product',array('id'=>$_SESSION['id'],'uniacid'=>$_SESSION['uniacid']),'content');
	if(!$content){
		exit('找不到内容！');
	}
	echo $content;
	exit;
}